from pylab import *
import scipy.ndimage
from fast12 import detect
import sys

import simplejson

if __name__ == '__main__':


    ion()


    if len(sys.argv) < 3:
        print sys.argv[0], '<job_file.json> <frame_number>'
        raise Exception('Insufficient number of parameters')

    finput = open(sys.argv[1])
    job_params = simplejson.load(finput)
    finput.close()

    fileroot = job_params['root_directory']


    for framenum in range(1):
        framenum = int(sys.argv[2])


        filename = fileroot+'/frames/'+job_params['filename_format']%framenum
        filename = fileroot+'/fastcorners/'+job_params['filename_format']%framenum


        img_color = imread(filename)
        # aa = 256*(scipy.ndimage.gaussian_filter( aa[:,:,0], 1.) +
        #           scipy.ndimage.gaussian_filter( aa[:,:,1], 1.) +
        #           scipy.ndimage.gaussian_filter( aa[:,:,2], 1.))
        img_gray = 256. * img_color.sum(2)

        sys.argv[1]

        features = detect(img_gray, 50., do_nonmax=1)




    # pp = array(features[0])

    # imshow(img_color)
    # #ylim(100,0)
    # plot(pp[:,0], pp[:,1], 'r+', mew=1)
    # axis('equal')

